package com.example.pay_service.config;
/**
 * @title: SwaggerConfig
 * @projectName s83-spring-cloud1
 * @description: TODO
 * @author TLJ
 * @date 2021/11/12 14:30
 */


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2//开启swagger框架能力支持
public class SwaggerConfig {

    @Bean
    //Docket保存所以文档信息的对象
    public Docket getSwagger(){
        return new Docket(DocumentationType.SWAGGER_2)
                //所有需要文档化的API（接口）对象
                .apiInfo(getApiInfo())
                //API构造选择器
                .select()
                //需要文档化的路径 已包名的方式指定生成文档的包路径
                //RequestHandlerSelectors.basePackage("sunjob.s83cloudauthcenter")
                //RequestHandlerSelectors.withClassAnnotation(Configuration.class)
                .apis(RequestHandlerSelectors.basePackage("sunjob.s83authentication"))
                //选择此包下所有标注了的接口接口生成文档
                .paths(PathSelectors.any())
                //build模式创建docket
                .build();
    }

    private ApiInfo getApiInfo(){
        //通过apibuild对象构建apiinfo对象
        return new ApiInfoBuilder()
                //指定标题
                .title("S83认证中心接口")
                //指定描述信息
                .description("这是认证中心接口详细信息")
                //指定版本信息
                .version("v1.0.0")
                //指定联系人信息
                .contact(new Contact("tlj","www.sunjob.com","aa@aa.com"))
                .build();
    }
}
